import {AsyncStorage} from 'react-native';
export function getAsyncStoreInfo(){
    return new Promise(resolve=>{
        AsyncStorage.getItem("app_data",(err,data)=>{
            if(err){
                resolve(null);
            }else{
                try {
                    let storeInfo = JSON.parse(data);
                    resolve(storeInfo)
                    global.storeInfo = storeInfo;
                }catch(e){
                    resolve(null);
                }
            }
        })
    })
}

export function getStoreInfo(){
    if(global.storeInfo){
        return global.storeInfo;
    }else{
        getAsyncStoreInfo();
        return null;
    }
}

export function setStoreInfo(info){
    global.storeInfo = info;
    AsyncStorage.setItem("app_data",JSON.stringify(info));
}